package pancake.function;

import java.util.ArrayList;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public class MyListAdapter extends BaseAdapter
{
	//private static final String TAG="ListAdapter";
	private Context context;
	private ArrayList<MyListFanItemView.Data> data;
	public MyListAdapter(Context context)
	{
		this.context = context;
	}
	public MyListAdapter(ArrayList<MyListFanItemView.Data> data)
	{
		this.data = data;
	}
	public MyListAdapter(Context context, ArrayList<MyListFanItemView.Data> data)
	{
		this.context= context;
		this.data = data;
	}
 
	public int getCount() {
		// TODO Auto-generated method stub
		return this.data.size();
	}
 
	public Object getItem(int location) {
		// TODO Auto-generated method stub
		return this.data.get(location);
	}
 
	public long getItemId(int location) {
		// TODO Auto-generated method stub
		return location;
	}
 
	public View getView(int location, View view, ViewGroup parent) {
		if(this.data==null) return null;
		 if(view ==null)
		 {
			 MyListFanItemView itemview = new MyListFanItemView(this.context); 
			 itemview.updateView(this.data.get(location));
			 view = itemview;
		 }
		 else
		 {
			 ((MyListFanItemView)view).updateView(this.data.get(location));
		 }
		 return view;
	}
}